<#assign menuId=2>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>设计订单-${Application.systemName!}</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- font Awesome -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Ionicons -->
        <link href="../css/ionicons.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />

        <link href="../css/myself.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="../css/pagination.css" />
        <script type="text/javascript" src="../js/lib/jquery.min.js"></script>
        <script type="text/javascript" src="../js/jquery.pagination.js"></script>


        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
        <style>
        	i{
        		cursor: pointer;
        	}
        	label {
			    font-weight: normal;
			}
			.find-row label{
				padding: 0 5px;
			} 
        	.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
			    vertical-align: middle;
			}
			
        	
        </style>
    </head>
    <body class="skin-blue">
        <!-- header logo: style can be found in header.less -->
        <#include "../header.html"/>
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- Left side column. contains the logo and sidebar -->
            <#include "../menu.html" />

            <!-- Right side column. Contains the navbar and content of the page -->
           <aside class="right-side">
           	<section class="content-header">
                    <h1>设计订单</h1>
                   <#if Session["permisionMap"]["F100"]??>
	                	<div class="pull-right" style="position: absolute; top: 10px; right: 20px;">
	                 	
							<button type="button" class="btn btn-primary fr margin" onclick="window.location.href='addPage'">${Session["permisionMap"]["F100"].name!}</button>
						</div>
               		</#if>
               		<hr style="margin: 10px 0 0 0" />
            </section>
            <section class="content">
            	<div class="row">
            		<div class="col-md-12">
            			<div class="box">
            			<div class="clearfix search-div center">
                            	<div class="design-order-top clearfix"  style="margin-bottom: 15px;">
					                <div  class="fl clearfix">
	                                    <div class="btn-group" data-toggle="btn-toggle">
						                  <button type="button" onclick="window.location.href='list?pageNo=1'" class="btn btn-default btn-md <#if status??><#else>active</#if>">全部
						                  </button>
						                  <button type="button"  onclick="window.location.href='list?pageNo=1&status=10'" class="btn btn-default btn-md  <#if status?? && status==10>active</#if>">待分配</button>
						         
						                  <button type="button"  onclick="window.location.href='list?pageNo=1&status=11'" class="btn btn-default btn-md <#if status?? && status==11>active</#if>">设计中</button>
						                 
						                  <button type="button"  onclick="window.location.href='list?pageNo=1&status=12'" class="btn btn-default btn-md <#if status?? && status==12>active</#if>">待审核</button>
						                
						                  <button type="button"  onclick="window.location.href='list?pageNo=1&status=99'" class="btn btn-default btn-md <#if status?? && status==99>active</#if>">已完成</button>
	                                    </div>
					                </div>
	            				</div>
	            				
	            				<div class="search1">
					            	<form action="list" method="post"> 
							       		<ul style="padding: 0;"> 
							       			<li>
												<input type="text" name="code" value="${code!}" placeholder="输入订单号"/>
							       			</li>
							       			<li>
												<input type="text" value="${customerName!}" name="customerName" placeholder="输入客户名称"/>
							       			</li>
							       			<li>
												<select class="input-md" name="isExceed" id="isExceed">
	                                                <option value="">是否超期</option>
	                                                <option value="1">是</option>
													<option value="0">否</option>
	                                        	</select>	
	                                        </li>						       			
							       			<li>
							       				<div>
				                                    <button type="submit" class="btn btn-primary btn-sm">搜索</button>
		                                		</div>
							       			</li>
							       		</ul>
							       		</form>
							       	</div> 
                            </div><!-- /.box-header -->
            				
				            <div class="clearfix search-div center" style="margin-top:0">
				               
				               
						       <div class="clearfix"></div>
						           <table class="table table-bordered text-center">
						               <tbody>
						                   <tr>
						                       <th style="border:0;" width="36%">公司信息</th>
						                       <th style="border:0;" width="17%">设计款数</th>
						                       <th style="border:0;" width="17%">设计师</th>
						                       <th style="border:0;" width="17%">状态</th>
						                       <th style="border:0;" width="17%">操作</th>
						                   </tr>
						               </tbody>
						           </table>
						            <#list orderList as order>
						           <table class="table text-center table-bordered order-list">
						
						                   <tr>
						                       <td colspan="5" class="left-text" style="font-weight: bold;">
						                           <span><#if order.createAt??>${order.createAt?string("yyyy-MM-dd")}</#if></span>
						                           <span>订单号：${order.code!}</span>
						                           <#if order.status  lt 99>
						                           <#if order.enddateCnt?? && order.enddateCnt gt 0>
						                           <b class="fr six-font">剩余${order.enddateCnt!}天</b>
						                           <#elseif order.enddateCnt?? && order.enddateCnt lt 0>
						                           <b class="fr six-font red">超期${order.enddateCnt?abs}天</b>
						                           <#else>
						                           <b class="fr six-font">剩余${order.enddateCnt!}天</b>
						                           </#if>
						                           </#if>
						                       </td>
						                   </tr>
						<tr>
						                        <td width="36%" style="vertical-align: top;">
						                            
						                            <#if order.customer.level=="V1">
						                            <i class="iconfont fl">&#xe6eb;</i>
						                            <#elseif order.customer.level=="V2">
						                            <i class="iconfont fl">&#xe6ed;</i>
						                            <#else>
						                            <i class="iconfont fl">&#xe6e9;</i>
						                            </#if>
						                            <div  class="order-text">
						                            <p>
						                            <a id="name" href="../customer/doShowCustomerDetailPage?id=${order.customer.id}">${order.customer.fullname!}</a>
						                            <#if order.customer.web??  && order.customer.web!="">
								                            <a href="${order.customer.web}"><i class="iconfont">&#xe6ee;</i></a>
								                            </#if>
								                            <#if order.customer.attachment?? && order.customer.attachment?size!=0>
								                            <a class="download"><i class="iconfont" data-toggle="modal" data-target="#myModal1${order_index}">&#xe6ef;</i></a>
						                            		<div class="modal fade" id="myModal1${order_index}"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
																<div class="modal-dialog down_load">
																	<div class="modal-content">
																		<div class="modal-header">
																			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
																				&times;
																			</button>
																			<h4 class="modal-title">
																				下载列表
																			</h4>
																		</div>
																		<div class="modal-body">
																			<ul>
																				<#list order.customer.attachment as attach>
																				<li>
																					<div class="clearfix">
																						<a href="../businessfile/downFile?businessFileId=${attach.id!}"><img class="pull-left" src="../img/file.png" style="width: 60px; height: 60px; border-radius: 10px;"/></a>
																						<span class="pull-left" title="${attach.originName!}">${attach.originName!}</span>
																					</div>
																				</li>
																				</#list>
																			</ul>
																		</div>
																		<div class="modal-footer">
																			<button type="button" class="btn btn-default" data-dismiss="modal">关闭
																			<btton>
																		</div>
																	</div><!-- /.modal-content -->
																</div><!-- /.modal -->
															</div>
															</#if>
						                            </p>
						                            <p>产品分类：<#list order.customer.productCategory as category>${category!}&nbsp;</#list> 目标人群：${order.customer.targetConsumer!}</p>
						                            <p>
						                            <#list order.customer.styleLabel as label>
						                            <span class="bule-border">${label!}</span>
						                            </#list>
						                            
						                            </p>
						                            </div>
						
						                        </td>
						                       <td width="17%">${order.orderPatternResults?size}</td>
						                       <td width="17%">${order.designerName!}</td>
						                       <td width="17%" class="red"><#if order.status==10>待分配<#elseif order.status==11>设计中
				                		<#elseif order.status==12>待审核<#elseif order.status==99>已完成<#elseif order.status==100>已关闭</#if></td>
				                		</td>
						                       <td width="17%">
						                        <#if (Session["permisionMap"]["F104"]??) && order.status==99>
						                        <div style="margin-bottom: 10px">
						                        	 <span class="btn btn-warning btn-sm"  onclick="closeOrder(${order.id},${order.orderId});">关闭订单</span> 
						                        </div>
                         
                         </#if>  
                         <#if (Session["permisionMap"]["F108"]??)  && order.status==99>
                           <div style="margin-bottom: 10px">
                           		<span class="btn btn-primary btn-sm" onclick="window.location.href='../proofingorder/add?orderId=${order.orderId}'">创建打样订单</span>   
                           </div>
                           
                         </#if>  
						           <#if (Session["permisionMap"]["F101"]??) && order.status lt 99>
						           <#if order.designer??>
						           <div>
			                				<a class="btn btn-primary btn-sm" style="margin-bottom: 10px" data-toggle="modal" data-target="#assign_user_${order_index}">修改设计师</a>
			                			</div>
						           <#else>
						           <div>
			                				<a class="btn btn-primary btn-sm" style="margin-bottom: 10px" data-toggle="modal" data-target="#assign_user_${order_index}">指派设计师</a>
			                			</div>
						           </#if>
						              
											 <div class="modal fade" id="assign_user_${order_index}"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
																			<div class="modal-dialog">
												<div class="modal-content">
													<div class="modal-header">
														<button type="button" class="close" data-dismiss="modal" 
																aria-hidden="true">×
														</button>
														<h4 class="modal-title" id="myModalLabel">
															指派设计师
														</h4>
													</div>
													<div class="modal-body">
														<form id="assignDesignerForm_${order_index}">
															<table class="table table-bordered">
					                                        	<tbody>
							                                        <tr>
							                                            <th style="width: 80px">选择</th>
							                                            <th>账号</th>
							                                            <th>姓名</th>
							                                        </tr>
							                                        <#list designerList as sysUser>
							                                        <tr>
							                                            <td><input type="radio" name="designer" value="${sysUser.id!}"  <#if order.designer?? && order.designer==sysUser.id>checked="checked" </#if>/></td>
							                                            <td>${sysUser.email!}</td>
							                                            <td>${sysUser.name!}</td>
							                                        </tr>
						                                       		</#list>
					                                    		</tbody>
					                                    	</table>
														</form>
													</div>
													<div class="modal-footer">
														<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
														<button type="button" onclick="assignDesigner('assignDesignerForm_${order_index}',${order.id})" id="btnassignuser" class="btn btn-primary">
															提交
														</button>
													</div>
												</div><!-- /.modal-content -->
											</div><!-- /.modal-dialog -->
										</div><!-- /.modal -->
				                		</#if>
				                		
				                		
				                		<#if (Session["permisionMap"]["F109"]??) && order.status lt 100>
				                		<#if order.manager??>
				                		<div>
			                				<a class="btn btn-primary btn-sm" style="margin-bottom: 10px" data-toggle="modal" data-target="#assign_manager_${order_index}">修改项目经理</a>
			                			</div>
				                		
				                		<#else>
				                		<div>
			                				<a class="btn btn-primary btn-sm" style="margin-bottom: 10px" data-toggle="modal" data-target="#assign_manager_${order_index}">指派项目经理</a>
			                			</div>
				                		
				                		</#if>
				                		
											 <div class="modal fade" id="assign_manager_${order_index}"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
																			<div class="modal-dialog">
												<div class="modal-content">
													<div class="modal-header">
														<button type="button" class="close" data-dismiss="modal" 
																aria-hidden="true">×
														</button>
														<h4 class="modal-title" id="myModalLabel">
															指派项目经理
														</h4>
													</div>
													<div class="modal-body">
										<form id="assignManagerForm_${order_index}">
										<table class="table table-bordered">
                                        <tbody><tr>
                                            <th style="width: 80px">选择</th>
                                            <th>账号</th>
                                            <th>姓名</th>
                                        </tr>
                                        <#list managerList as sysUser>
                                        <tr>
                                            <td><input type="radio" name="manager" value="${sysUser.id!}"  <#if order.manager?? && order.manager==sysUser.id>checked="checked" </#if>/></td>
                                            <td>${sysUser.email!}</td>
                                            <td>${sysUser.name!}</td>
                                        </tr>
                                       </#list>
                                    </tbody></table>
									</form>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-default" 
													data-dismiss="modal">关闭
											</button>
											<button type="button" onclick="assignManager('assignManagerForm_${order_index}',${order.orderId})" id="btnassignuser" class="btn btn-primary">
												提交
											</button>
										</div>
									</div><!-- /.modal-content -->
								</div><!-- /.modal-dialog -->
							</div><!-- /.modal -->
				                		</#if>
				                		<!-- 
				                		<#if (Session["permisionMap"]["F102"]??)  && order.status==11>
				                		<div class="">
				                		
				                				<button type="button" style="margin-bottom: 10px" onclick="window.location.href='../orderpattern/addPage?businessId=${order.id}&orderId=${order.orderId!}'" class="btn btn-primary">${Session["permisionMap"]["F102"].name!}</button>
				                			</div>
				                		</#if>
				                		 -->
				                		 <#if (order.designer??) && (Session["userId"]==order.designer) && (Session["permisionMap"]["F102"]??)  && order.status==11> 
	                         <#if order.orderPatternResults?size lt order.designCount>
	                        	<div style="margin-bottom: 10px">
	                        		<span class="btn btn-primary btn-sm" onclick="window.location.href='../orderpattern/addPage?businessId=${order.id}&orderId=${order.orderId}'">上传设计稿</span>
	                        	</div>
	                         
	                         </#if>
                        </#if>
				                		<#if (Session["permisionMap"]["F103"]??) && order.status==12>
                        					<div class="">
				                		
				                				<button type="button" style="margin-bottom: 10px" onclick="verify(${order.id},${order.orderId!})" class="btn btn-primary btn-sm">通过审核</button>
				                			</div>  
                         </#if>
                         <#if (order.designer??) && (Session["userId"]==order.designer) && (Session["permisionMap"]["F105"]??) && order.status==11>
	                    	 <#if order.orderPatternResults?size &gt;= order.designCount>
	                         <span class="btn btn-warning" onclick="submitVerify(${order.id},${order.orderId})">提交审核</span> 
	                         </#if>
                         </#if>
				                			<div class="">
				                				<a href="detail?businessId=${order.id}&orderId=${order.orderId!}">订单详情</a>
				                			</div>
						                           
						                       </td>
						       </tr>
						           </table>
						           </#list> 
							    <div class="box-footer clearfix">
                                    <ul class="pagination pagination-sm no-margin pull-right">
                                        <#if splitPage??> ${splitPage?replace("{url}","${path}")}</#if>
                                    </ul>
                                </div>
				           	</div>
                            
                            
            			</div>
            		</div>
            	</div>
            </section>
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
        <!-- jQuery 2.0.2 -->
      <!-- 模态框（Modal） -->
	
	
        <!-- Bootstrap -->
        <script src="../js/bootstrap.min.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="../js/AdminLTE/app.js" type="text/javascript"></script>
        <script src="../js/jquery.form.min.js"></script>
		<!-- Page script -->
		<script type="text/javascript">
	          
			$(function() {
				$('#isExceed').val(${isExceed!});
				
			});
			function assignDesigner(formId,businessId){
				$("#"+formId).ajaxSubmit({  
    	            type : "POST",  
    	            url : "assignDesigner",   
    	            dataType : "json",  
    	            data:{businessIds:businessId},
    	            contentType : 'application/x-www-form-urlencoded; charset=UTF-8',  
    	            success : function(map) {  
    	            	
    	                if(map.head.respCode=="0000000"){
    	                	alert("保存成功");
    					    window.location.href="list?pageNo=${pageNo!}";
    	                }else{
    	                	alert(map.body);
    	                }
    	            },  
    	            error : function(map) {  
    	                alert("出现错误，请刷新页面");  
    	            }  
    	  
    	        }) 
			}
			 function closeOrder(designOrderId,orderId){
		         confirm("是否确定关闭订单操作?",function(flag){
		        	 if(!flag){
		        		 return;
		        	 }
		        	 $.ajax({
			                url:'closeorder',
			                type:'POST', //GET
			                data:{
			                	businessId:designOrderId,orderId:orderId
			                },
			                dataType:'json',    
			               
			                success:function(data){
			                	if(data.head.respCode=="0000000"){
			                		alert("提交成功");
			                		window.location.href="list?pageNo=${pageNo!}";
			                	}else{
			                		alert(data.body)
			                	}
			                },
			                error:function(xhr,textStatus){
			                    console.log('错误')
			                    alert("错误");
			                }
			            })
		         })
		         
			}
			function assignManager(formId,businessId){
				$("#"+formId).ajaxSubmit({  
    	            type : "POST",  
    	            url : "../order/assignManager",   
    	            dataType : "json",  
    	            data:{businessIds:businessId},
    	            contentType : 'application/x-www-form-urlencoded; charset=UTF-8',  
    	            success : function(map) {  
    	            	
    	                if(map.head.respCode=="0000000"){
    	                	success("保存成功",function(){
    	                		window.location.href="list?pageNo=${pageNo!}";
    	                	});
    					    
    	                }else{
    	                	alert(map.body);
    	                }
    	            },  
    	            error : function(map) {  
    	                alert("出现错误，请刷新页面");  
    	            }  
    	  
    	        }) 
			}
			 function verify(businessId,orderId){
				 confirm("是否确定订单通过审核?",function(flag){
					 if(!flag) return false;
					 $.ajax({
			                url:'verify',
			                type:'POST', //GET
			                data:{
			                	businessId:businessId,orderId:orderId
			                },
			                dataType:'json',    
			               
			                success:function(data){
			                	if(data.head.respCode=="0000000"){
			                		alert("提交成功");
			                		window.location.href="list?pageNo=${pageNo!}";
			                	}else{
			                		alert(data.body)
			                	}
			                	 
			                },
			                error:function(xhr,textStatus){
			                    console.log('错误')
			                    alert("错误");
			                }
			            })
				 	});
		        }
			 
			 
			 function submitVerify(businessId,orderId){
			        
		            confirm("是否确定将订单提交给设计总监审核?",function(flag){
		            	if(!flag){
		            		return;
		            	}
		            	$.ajax({
		                    url:'submitverify',
		                    type:'POST', //GET
		                    data:{
		                    	businessId:businessId,orderId:orderId
		                    },
		                    dataType:'json',    
		                   
		                    success:function(data){
		                    	if(data.head.respCode=="0000000"){
		                    		alert("提交成功");
		                    		window.location.href="list?pageNo=${pageNo!}";
		                    	}else{
		                    		alert(data.body)
		                    	}
		                    },
		                    error:function(xhr,textStatus){
		                        console.log('错误')
		                    }
		                })
		            })
		            
		        	
		        }
		</script>


    </body>
</html>
